package com.zhiy.com.estation.ui.fragment.login;

import com.zhiy.com.estation.model.User;
import com.zhiy.com.estation.api.ApiResult;

import io.reactivex.functions.Consumer;

/**
 * Created by Zyh on 2016/12/3.
 */
public class LoginPresenter extends LoginContract.Presenter {
    @Override
    public void login(String name, String password) {
        model.login(name,password)
                .subscribe(new Consumer<ApiResult<User>>() {
                    @Override
                    public void accept(ApiResult<User> apiResult) throws Exception {
                        view.showMsg(apiResult.getMsg());
                        if (apiResult.getCode()==0){
                            view.isLoginSuccess(apiResult.getData());
                        }else {
                            view.isFailure();
                        }
                    }
                });
    }
}
